package com.wk.unreal.yyzxserver.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wk.unreal.yyzxserver.dto.PageBean;
import com.wk.unreal.yyzxserver.dto.Result;
import com.wk.unreal.yyzxserver.entity.BedDetails;
import com.wk.unreal.yyzxserver.mapper.BedMapper;
import com.wk.unreal.yyzxserver.service.BedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BedServiceImpl implements BedService {

    @Autowired
    private BedMapper bedMapper;

    @Override
    public Result findByCustomerNameDedDetails(String customerName, Integer pageNum, Integer pageSize) {

        PageHelper.startPage(pageNum, pageSize);
        List<BedDetails> bedDetails = bedMapper.selectBedDetails(customerName);
        Page page = (Page) bedDetails;

        PageBean<BedDetails> pageBean = new PageBean<>();
        // 总记录数
        pageBean.setTotal(page.getTotal());
        // 分页查询之后的数据
        pageBean.setData(page.getResult());

        return Result.success().data(pageBean);
    }
}
